/*
 * Licensed to Nanjing RedOrange Co. ltd (RedOrange) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * RedOrange licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package redora.rdo.api;

import java.util.Date;

/**
 * Classic pagination. When the query is executed the first time it is determined 
 * how many records the query will retrieve. With this information the user interface can show something like:<br>
 * previous 1 2 3 4 ... 99 100 101 next last<br>
 * Because the underlying table can change during the time the user will press some of these buttons,
 * the implementation should handle these cases when this happens.
 * 
 * @author jaap
 *
 */
public interface Page {
	public int pageSize();
	public int position();
	public int resultCount();
	public int pageCount();
	public boolean isRetrieved(int position);
	public Date firstAccessed();
	public String toJSON();
	
	public void setPageSize(int pageSize);
	public boolean hasMoreRecords();
	/**
	 * Fetches the next page of records.
	 * @return True If new records were found.
	 */
	public boolean next();
	/**
	 * Moves to the last page. 
	 * @return
	 */
	public boolean last();
	public void get(int position);
	public void clear();
	
}
